
#ifndef DEBUG_H_
#define DEBUG_H_

#include "Core.h"

namespace p2 {

class Debug
{
private:
	static char const* s_logFile;
	static Timer s_logTimer;
	static char const* s_assertFormat;
public:
	static void assertLog(char const* file, int32 line, char const* cond);
	static void log(char const* file, int32 line, char const* msg);
	static void logF(char const* file, int32 line, char const* fmt, ...);
};

#define LOG(msg)                   		Debug::log(__FILE__, __LINE__, msg)
#define LOGF(fmt, ...)             		Debug::logF(__FILE__, __LINE__, fmt, __VA_ARGS__)
#ifdef DEBUG
#	define ASSERTLOG(cond, msg)			if (!(cond)) {	\
											Debug::assertLog(__FILE__, __LINE__, STRINGISE(cond));	\
										}
#	define CONSOLE(msg)		        	fprintf(stdout, (msg)); \
										fputc('\n', stdout);	\
										fflush(stdout);
#	define CONSOLEF(fmt, ...)         	fprintf(stdout, (fmt), __VA_ARGS__); \
										fputc('\n', stdout);	\
										fflush(stdout);
#else
#	define ASSERTLOG(cond, msg)
#	define CONSOLE(msg)
#	define CONSOLEF(fmt, ...)
#endif

}

#endif
